package com.atjiao.cloud.Mapper;

import com.atjiao.cloud.Entity.demo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author jyp
 * @data 2025/3/13
 */
@Mapper
public interface DemoMapper {

    // 插入鱼类监测数据
    @Insert("INSERT INTO fish_monitoring (area, mortality, survivalRate, fishMonitoring) " +
            "VALUES (#{area}, #{mortality}, #{survivalRate}, #{fishMonitoring})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertFishMonitoring(demo fishMonitoring);

    // 根据ID删除鱼类监测数据
    @Delete("DELETE FROM fish_monitoring WHERE id = #{id}")
    int deleteFishMonitoringById(Integer id);

    // 更新鱼类监测数据
    @Update("UPDATE fish_monitoring SET area = #{area}, mortality = #{mortality}, " +
            "survivalRate = #{survivalRate}, fishMonitoring = #{fishMonitoring} " +
            "WHERE id = #{id}")
    int updateFishMonitoring(demo fishMonitoring);

    // 查询所有鱼类监测数据
    @Select("SELECT * FROM fish_monitoring")
    List<demo> getAllFishMonitoring();

    // 根据ID查询鱼类监测数据
    @Select("SELECT * FROM fish_monitoring WHERE id = #{id}")
    demo getFishMonitoringById(Integer id);
}
